# include<stdio.h>

int main()
{
    #if 0
    printf("I have a dream");   //#if*******#endif之间的内容可以被逻辑删除，能避免代码原先存在的/*的影响
    #endif
    int array[]={32,45,33,76,54,66,22,73,21,33};
    int target;
    int arrayLen;
    printf("Please enter the target you wanted:");
    scanf("%d",&target);
    arrayLen=sizeof(array)/sizeof(array[0]);
    int index=-1;
    int low=0,hight=arrayLen-1,mid;
    while(low<=hight)
    {
        mid=(low+hight)/2;
        if(array[mid]==target)
        {
            index=mid;
            break;
        }
        else if(array[mid]<target)
        low=mid+1;
        else    hight=mid-1;

    }
    if(index==-1)
    printf("sorry,can't find the target!\n");
    else printf("the index of the target is %d\n",index);
    return 0;
}
// 二分查找只能在数据有序的前提下才能使用，此方法可以比顺序查找更快捷